package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsFriendlyLink;
import com.ruoyi.system.domain.news.query.NewsFriendlyLinkQuery;
import com.ruoyi.system.domain.news.vo.NewsFriendlyLinkVo;
import com.ruoyi.system.domain.news.vo.NewsFriendlyLinkVo;
import com.ruoyi.system.mapper.news.NewsFriendlyLinkMapper;
import com.ruoyi.system.service.news.NewsFriendlyLinkService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsFriendlyLinkServiceImpl extends ServiceImpl<NewsFriendlyLinkMapper, NewsFriendlyLink>
        implements NewsFriendlyLinkService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsFriendlyLinkVo> getNewsFriendlyLinkList(NewsFriendlyLinkQuery newsFriendlyLinkQuery) {
        if (newsFriendlyLinkQuery.getIfPage()) {
            PageHelper.startPage(newsFriendlyLinkQuery.getPageNum(), newsFriendlyLinkQuery.getPageSize());
        }
        List<NewsFriendlyLinkVo> newsFriendlyLinkVoList = baseMapper.getNewsFriendlyLinkList(newsFriendlyLinkQuery);
        if (!newsFriendlyLinkVoList.isEmpty() && newsFriendlyLinkQuery.getId() == null) {
            for (NewsFriendlyLinkVo newsFriendlyLinkVo:newsFriendlyLinkVoList) {
                newsFriendlyLinkVo.setContent(null);
            }
        }
        return newsFriendlyLinkVoList;
    }
}
